﻿using Sgr.Domain.Repositories;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.UPMS.Domain.Tokens
{
    /// <summary>
    /// 临时令牌仓储接口
    /// </summary>
    public interface ITemporaryTokenRepository : IBaseRepositoryOfTEntityAndTPrimaryKey<TemporaryToken, long>
    {
        /// <summary>
        /// 是否存在指定编码的令牌
        /// </summary>
        /// <param name="code">令牌编码</param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<bool> ExistsCodeAsync(string code, CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据编码获取临时令牌
        /// </summary>
        /// <param name="code">令牌编码</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<TemporaryToken?> GetByCodeAsync(string code, CancellationToken cancellationToken = default);
    }
}